package com.zr.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zr.dao.BaseDao;
import com.zr.dao.UserDao;

import com.zr.dao.impl.UserDaoImpl;

import com.zr.model.Role;
import com.zr.model.User;
import com.zr.service.UserService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Service("userService")
public class UserServiceImpl implements  UserService{
	
	@Resource
	private BaseDao<Object>  baseDao;
	@Resource
	private  UserDao<User>  userDao;
	@Override
	public User findUserByuserNameanduserPsw(User user) {
		// TODO Auto-generated method stub
		String hql = "from User u where u.uname=? and u.upsw=?";
		User u=(User) baseDao.get(hql,new Object[]{user.getUname(),user.getUpsw()});
		return u; 
	}
	
	@Override
	public Role findrole(int rid) {
		String hql = "from Role r where r.rid=? ";
		return (Role) baseDao.get(hql,new Object[]{rid});		
	}
	@Override
	public JSONArray findfuns(int pid, String funcs) {
	    
			return userDao.getAllFunction(pid, funcs);
		
	}
	
	

}
